package com.wz.service.impl;

import com.domain.Account;
import com.wz.dao.AccountDao;
import com.wz.service.AccountService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/*@Service*/
@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;
    
    @Override
    @Transactional
    public boolean transport(Integer uuuid1, Integer uuuid2, Double money) {
        Double orgMoney1 = accountDao.get(uuuid1).getMoney();
        Double orgMoney2 = accountDao.get(uuuid2).getMoney();
        
       accountDao.update(uuuid1,orgMoney1-money);
      // int i = 1 / 0;
       accountDao.update(uuuid2,orgMoney2+money);
        return true;
    }

    @Override
    public Account findByUuuid(Integer uuuid) {
        
        return accountDao.get(uuuid);
    }
}
